<template>
	<z-container left-icon-size="0" navBgColor="transparent" pageBgName="my-bg">
		<view class="ss-p-x-40">
			<uv-gap height="48rpx"></uv-gap>
			<view @tap="handleLogin" class="ss-flex">
				<z-avatar :src="userInfo.avatar" size="156rpx" />
				<view v-if="isLogin" class="ss-flex-col ss-m-l-32">
					<view class="ss-flex ">
						<view class=" ss-line-1 font-w-500">{{ userInfo.nickname }}</view>
						<view class="tag">{{ userInfo.storesf?.name }}</view>
					</view>
					<view class="ss-flex ss-m-t-24">
						<z-icon name="phone" size="32rpx"></z-icon>
						<view class="fc-dark6 ss-m-l-8">{{ sheep.$helper.hidePhoneNumber(userInfo.mobile) }}</view>
					</view>
				</view>
				<view v-else class="ss-flex-col ss-m-l-32 ss-font-32 font-w-500">账号密码登录</view>   
			</view>
			<uv-gap height="64rpx"></uv-gap>
			<IncomeInfo />
			<view class="bg-white br-24 ss-m-t-32 ss-p-x-40">
				<view @tap="toPage(item)" v-for="(item,index) in myActions" :key="item.name" class="ss-flex ss-row-between ss-p-y-40" :class="index + 1 != myActions.length?'b-b':''">
					<view class="ss-flex">
						<z-icon :name="item.icon" size="56rpx"></z-icon>
						<view class="ss-m-l-18 font-w-500 fs-28">{{ item.name }}</view>
					</view>
					<z-icon builtIn name="arrow-right" size="32rpx" color="#A7A7A7"></z-icon>	
				</view>
			</view>
			<uv-gap height="25"></uv-gap>
			<z-button v-if="isLogin" @tap="sheep.$store('user').logout()">退出登录</z-button>
		</view>
	</z-container>
</template>

<script setup>
	import sheep from "@/sheep"
	import { myActions } from "@/sheep/enu/index.js"
	import IncomeInfo from "@/pages/index/components/IncomeInfo.vue"
	const userInfo = computed(() => sheep.$store('user').userInfo)
	const isLogin = computed(() => sheep.$store('user').isLogin)
	function toPage(item) {
		sheep.$router.go(item.url)
	}
	function handleLogin() {
		if (!isLogin.value) {
			sheep.$router.go('/pages/login/login')
		}
	}
	//下拉刷新
	onPullDownRefresh(() => {
	  sheep.$store('user').getInfo()
	  setTimeout(function () {
	    uni.stopPullDownRefresh();
	  }, 800);
	});
</script>

<style lang="scss" scoped>
	.b-b {
		border-bottom: 1rpx solid #eee;
	}
</style>
